<%@page import="javax.portlet.PortletURL"%>
<%@page import="com.bkav.portal.potlet.model.Employee"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.liferay.portal.kernel.util.StringUtil"%>
<%@page import="com.bkav.portal.potlet.service.EmployeeLocalServiceUtil"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ include file="/html/employee/init.jsp"%>
<portlet:defineObjects />

<b>Employee Add </b>
<portlet:renderURL var="updateEmployeeURL">
	<portlet:param name="jspPage" value="/html/employee/edit.jsp" />
</portlet:renderURL>
<br />
<br />
<portlet:actionURL var="addEmployeeURL" name="addEmployee" />
<aui:form name="fm" method="POST"
	action="<%=addEmployeeURL.toString()%>">
	<aui:input name="employeeName" label="Employee Name" />
	<aui:input name="employeeDesc" label="Employee Desc" />
	<aui:input name="employeeJob" label="Employee Job" />
	</br>
	<aui:button type="submit" value="Save"
		onClick="alert('them moi employee nhe!')" />
</aui:form>
<br />
<br />

		
<!-- --------------------------------------------------------------------- -->
<%                  
List<Employee> listEmployee = EmployeeLocalServiceUtil.getEmployees(0, 100);                   
%>

<%
PortletURL iteratorURL= renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/html/employee/view.jsp");
%>

<liferay-ui:search-container delta="20" iteratorURL="<%=iteratorURL%>"> 
       <liferay-ui:search-container-results
              results="<%=ListUtil.subList(listEmployee, searchContainer.getStart(),searchContainer.getEnd())%>"
                      total="<%=listEmployee.size() %>"/>
       <liferay-ui:search-container-row
       className="com.bkav.portal.potlet.model.Employee"
       modelVar="employee" rowVar="">  
              <liferay-ui:search-container-column-text name="Id" align = "left" value="<%= StringUtil.valueOf(employee.getEmployeeId()) %>"/>
              <liferay-ui:search-container-column-text name="Name" align = "left" value="<%=employee.getEmployeeName()%>"/>
              <liferay-ui:search-container-column-text name="Desc" align = "left" value="<%=employee.getEmployeeDesc()%>"/>
              <liferay-ui:search-container-column-text name="Job" align = "left" value="<%=employee.getEmployeeJob()%>"/>
    <liferay-ui:search-container-column-text name="Option" align="left">
			<a
				href="
                                  <portlet:renderURL>
                                         <portlet:param name="jspPage" value="/html/employee/edit.jsp" />
                                         <portlet:param name="employeeId" value="<%=StringUtil.valueOf(employee.getEmployeeId())%>" />
                                  </portlet:renderURL>                           
                                  ">Edit</a>
              &nbsp;|&nbsp;
               <a onClick="alert('ban co chac chan xoa ?')"
				href="
                             <portlet:actionURL name="removeEmployee">
                                   <portlet:param name="employeeId" value="<%=StringUtil.valueOf(employee.getEmployeeId())%>" />
                             </portlet:actionURL>
                        ">Remove</a>
		</liferay-ui:search-container-column-text>
    </liferay-ui:search-container-row>	 
     <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" paginate="true"/>   
    
</liferay-ui:search-container>
<br/>
<br/>
<br/>
<hr/>
<br />
<a href="<portlet:renderURL/>">&laquo;Go Back</a>